DistMatrix Subroutine

private subroutine DistMatrix(stations)

A subroutine to assemble the global distance. This operation is only carried out once; kriging observations matricies are subsetted from this lookup table to speed up processing.

Arguments

Type IntentOptional Attributes Name
type(ObservationalNetwork), intent(in) :: stations

Variables

Type Visibility Attributes Name Initial
type(pairs), public :: comp
integer(kind=short), public :: i
integer(kind=short), public :: j
integer(kind=short), public :: n

Source Code

SUBROUTINE DistMatrix &
!
(stations)


IMPLICIT NONE

!Arguments with intent (in):
TYPE (ObservationalNetwork), INTENT(IN) :: stations

!Local declarations
INTEGER (KIND = short) :: i, j, n
TYPE (pairs) ::  comp
  
  
!---------------------------end of declarations--------------------------------
!allocate square matrix where n is the number of available observation points
n = stations % countobs
ALLOCATE(obsdist(n,n))

!set points coordinate reference system
point1 % system = stations % mapping
point2 % system = stations % mapping

DO i=1,n
	DO j=1,n
        !set point1
        point1 % northing = stations % obs (i) % xyz % northing  
        point1 % easting = stations % obs (i) % xyz % easting 
        
        !set point2  
        point2 % northing = stations % obs (j) % xyz % northing  
        point2 % easting = stations % obs (j) % xyz % easting
        
        !prepare pair
        comp % p1 = i
        comp % p2 = j
        comp % h = Distance (point1,point2) 
        
        !populate distance matrix
        obsdist(i,j) = comp
        
	END DO
		
END DO
  
RETURN
END SUBROUTINE DistMatrix